unsigned int i = 0;
for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) {
- *name = (char*) default_guids[i].name;
+ *name = const_cast<char*>(default_guids[i].name);
return 1;
}
}
ed->prjlongitude = prjlon;
ed->frac = frac;
ed->arcpt1 = arcpt1;
- ed->arcpt2 = (Waypoint*) arcpt2;
+ ed->arcpt2 = const_cast<Waypoint*>(arcpt2);
}
}
waypointp->extra_data = ed;
}
}
}
- arcpt1 = (Waypoint*) arcpt2;
+ arcpt1 = const_cast<Waypoint*>(arcpt2);
}
void ArcDistanceFilter::arcdist_arc_disp_hdr_cb(const route_head*)
if ((*cp & 0xc0) != 0x80) {
break; /* invalid */
} else if (i == 0) { /* all valid */
- char* c = (char*)str; /* found valid sequence, now storing value */
+ char* c = const_cast<char*>(str); /* found valid sequence, now storing value */
int res = *c++ & (mask ^ 0xFF);
i = len;
while (i-- > 0) {
{
cet_ucs4_link_t* link;
- if ((link = (cet_ucs4_link_t*)vec->ucs4_link)) {
+ if ((link = const_cast<cet_ucs4_link_t*>(vec->ucs4_link))) {
int i = 0;
int j = vec->ucs4_links - 1; /* validate ucs value against vec */
while (i <= j) {
}
}
- if ((link = (cet_ucs4_link_t*)vec->ucs4_extra)) { /* can be NULL */
+ if ((link = const_cast<cet_ucs4_link_t*>(vec->ucs4_extra))) { /* can be NULL */
int i = 0;
int j = vec->ucs4_extras - 1;
while (i <= j) {
char*
cet_str_utf8_to_any(const char* src, const cet_cs_vec_t* vec)
{
- char* c = (char*)src;
+ char* c = const_cast<char*>(src);
int len;
char* res, *dest, *cend;
char* result, *cin, *cout;
char temp = CET_NOT_CONVERTABLE_DEFAULT;
- cin = (char*)src;
+ cin = const_cast<char*>(src);
if (cin == nullptr) {
return nullptr;
}
}
result = cout = (char*) xmalloc(len + 1);
- cin = (char*)src;
+ cin = const_cast<char*>(src);
while (*cin != '\0') {
if (CET_ERROR == cet_char_to_ucs4(*cin++, vec, &value)) {
for (p = cet_cs_vec_root; p != nullptr; p = p->next) {
c++;
if (p->alias != nullptr) {
- char** a = (char**)p->alias;
+ char** a = const_cast<char**>(p->alias);
while ((*a) != nullptr) {
a++;
c++;
i = 0;
for (p = cet_cs_vec_root; p != nullptr; p = p->next) {
if (p->alias != nullptr) {
- char** a = (char**)p->alias;
+ char** a = const_cast<char**>(p->alias);
list[i].name = xstrdup(p->name);
list[i].vec = p;
static void
cet_flag_waypt(const Waypoint* wpt)
{
- ((Waypoint*)(wpt))->wpt_flags.cet_converted = 1;
+ (const_cast<Waypoint*>(wpt))->wpt_flags.cet_converted = 1;
}
static void
cet_flag_route(const route_head* rte)
{
- ((route_head*)(rte))->cet_converted = 1;
+ (const_cast<route_head*>(rte))->cet_converted = 1;
}
static void
static void
cet_convert_waypt(const Waypoint* wpt)
{
- Waypoint* w = (Waypoint*)wpt;
+ Waypoint* w = const_cast<Waypoint*>(wpt);
format_specific_data* fs;
if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) {
static void
cet_convert_route_hdr(const route_head* route)
{
- route_head* rte = (route_head*)route;
+ route_head* rte = const_cast<route_head*>(route);
if ((cet_output == 0) && (rte->cet_converted != 0)) {
return;
cet_output = 1;
converter = cet_convert_from_utf8;
- cs_name_from = (char*)cet_cs_vec_utf8.name;
- cs_name_to = (char*)target->name;
+ cs_name_from = const_cast<char*>(cet_cs_vec_utf8.name);
+ cs_name_to = const_cast<char*>(target->name);
} else {
if ((target != nullptr) && (target != &cet_cs_vec_utf8)) {
fatal(MYNAME ": Internal error!\n");
cet_output = 0;
converter = cet_convert_to_utf8;
- cs_name_to = (char*)cet_cs_vec_utf8.name;
- cs_name_from = (char*)source->name;
+ cs_name_to = const_cast<char*>(cet_cs_vec_utf8.name);
+ cs_name_from = const_cast<char*>(source->name);
}
if (global_opts.debug_level > 0) {
static void
write_route_hdr_cb(const route_head* rte)
{
- curr_route = (route_head*) rte;
+ curr_route = const_cast<route_head*>(rte);
curr_index++;
if (curr_index != target_index) {
return;
write_track_hdr_cb(const route_head* trk)
{
track_info_flag = 0;
- curr_track = (route_head*) trk;
+ curr_track = const_cast<route_head*>(trk);
curr_index++;
if (curr_index != target_index) {
}
route_add_wpt(temp_route, new Waypoint(*wpt));
}
- track_add_wpt((route_head*)track, wpt);
+ track_add_wpt(const_cast<route_head*>(track), wpt);
}
static char*
*c = '.';
}
} else {
- buff = (char*)instr;
+ buff = const_cast<char*>(instr);
}
cur = buff;
csv_route = csv_track = nullptr;
switch (xcsv_file.datatype) {
case trkdata:
- csv_track = (route_head*) head;
+ csv_track = const_cast<route_head*>(head);
break;
case rtedata:
- csv_route = (route_head*) head;
+ csv_route = const_cast<route_head*>(head);
break;
default:
break;
int delh = 0;
int delv = 0;
- Waypoint* waypointp = (Waypoint*) wpt;
+ Waypoint* waypointp = const_cast<Waypoint*>(wpt);
if ((hdopf >= 0.0) && (waypointp->hdop > hdopf)) {
delh = 1;
void DiscardFilter::fix_process_head(const route_head* trk)
{
- head = (route_head*)trk;
+ head = const_cast<route_head*>(trk);
}
void DiscardFilter::process()
for (i = 0; i < wpt_a_ct; i++) { /* check for duplicates */
Waypoint* tmp = wpt_a[i];
if (case_ignore_strcmp(tmp->shortname, wpt->shortname) == 0) {
- wpt_a[i] = (Waypoint*)wpt;
+ wpt_a[i] = const_cast<Waypoint*>(wpt);
waypoints--;
return;
}
}
- wpt_a[wpt_a_ct++] = (Waypoint*)wpt;
+ wpt_a[wpt_a_ct++] = const_cast<Waypoint*>(wpt);
}
}
cur_info->time += (wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t());
cur_info->length += waypt_distance_ex(prev, wpt);
} else {
- cur_info->first_wpt = (Waypoint*)wpt;
+ cur_info->first_wpt = const_cast<Waypoint*>(wpt);
cur_info->start = wpt->GetCreationTime().toTime_t();
}
- cur_info->prev_wpt = (Waypoint*)wpt;
+ cur_info->prev_wpt = const_cast<Waypoint*>(wpt);
cur_info->count++;
routepoints++;
}
static void
route_disp_hdr_cb(const route_head* rte)
{
- current_trk = (route_head*)rte;
+ current_trk = const_cast<route_head*>(rte);
cur_info = &route_info[route_idx];
cur_info->prev_wpt = nullptr;
cur_info->total = 0;
gbfprintf(fout, "\r\n");
- cur_info->prev_wpt = (Waypoint*)wpt;
+ cur_info->prev_wpt = const_cast<Waypoint*>(wpt);
}
static void
cur_info = &route_info[route_idx];
cur_info->prev_wpt = nullptr;
cur_info->total = 0;
- current_trk = (route_head*)track;
+ current_trk = const_cast<route_head*>(track);
if (track->rte_waypt_ct <= 0) {
return;
}
}
gbfprintf(fout, "\r\n");
- cur_info->prev_wpt = (Waypoint*)wpt;
+ cur_info->prev_wpt = const_cast<Waypoint*>(wpt);
}
/*******************************************************************************
/* do this when backup always happens in main */
#if NEW_STRINGS
// but, but, casting away the const here is wrong...
- ((Waypoint*)refpt)->shortname = refpt->shortname.trimmed();
+ (const_cast<Waypoint*>(refpt))->shortname = refpt->shortname.trimmed();
#else
rtrim(((Waypoint*)refpt)->shortname);
#endif
void HeightFilter::correct_height(const Waypoint* wpt)
{
- Waypoint* waypointp = (Waypoint*) wpt;
+ Waypoint* waypointp = const_cast<Waypoint*>(wpt);
if (waypointp->altitude != unknown_alt) {
if (addopt) {
xasprintf(&key, "%s\01%.9f\01%.9f", CSTRc(wpt->shortname), wpt->latitude, wpt->longitude);
if (!(tmpwpt = map[key])) {
- tmpwpt = (Waypoint*)wpt;
- map[key] = (Waypoint*) wpt;
+ tmpwpt = const_cast<Waypoint*>(wpt);
+ map[key] = const_cast<Waypoint*>(wpt);
tmpwpt->extra_data = gb_int2ptr(waypoint_num + 1); /* NOT NULL */
humminbird_write_waypoint(wpt);
} else {
void* p = tmpwpt->extra_data;
- tmpwpt = (Waypoint*)wpt;
+ tmpwpt = const_cast<Waypoint*>(wpt);
tmpwpt->extra_data = p;
}
register_waypt(const Waypoint* ref)
{
int i;
- Waypoint* wpt = (Waypoint*) ref;
+ Waypoint* wpt = const_cast<Waypoint*>(ref);
for (i = 0; i < waypt_table_ct; i++) {
Waypoint* cmp = waypt_table[i];
mmo_data_t* data;
data = (mmo_data_t*) xcalloc(1, sizeof(*data));
- data->data = (void*)ptr;
+ data->data = const_cast<void*>(ptr);
data->visible = 1;
data->locked = 0;
data->type = type;
static void
mmo_finalize_rtept_cb(const Waypoint* wptref)
{
- Waypoint* wpt = (Waypoint*)wptref;
+ Waypoint* wpt = const_cast<Waypoint*>(wptref);
if ((wpt->shortname[0] == 1) && (wpt->latitude == 0) && (wpt->longitude == 0)) {
mmo_data_t* data;
return;
}
- mmo_rte = (route_head*)rte;
+ mmo_rte = const_cast<route_head*>(rte);
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
Waypoint* wpt = (Waypoint*)elem;
{
utf_string utf;
utf.is_html = true;
- utf.utfstring = (char*)str;
+ utf.utfstring = const_cast<char*>(str);
return strip_html(&utf); // util.cc
}
osm_release_ids(const Waypoint* wpt)
{
if (wpt && wpt->extra_data) {
- Waypoint* tmp = (Waypoint*)wpt;
+ Waypoint* tmp = const_cast<Waypoint*>(wpt);
xfree(tmp->extra_data);
tmp->extra_data = nullptr;
}
id = (int*) xmalloc(sizeof(*id));
*id = --node_id;
- ((Waypoint*)(wpt))->extra_data = id;
+ (const_cast<Waypoint*>(wpt))->extra_data = id;
gbfprintf(fout, " <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, wpt->latitude, wpt->longitude);
if (wpt->creation_time.isValid()) {
int i = rh->rte_waypt_ct;
if (i) {
- cur_rte = (route_head*)rh;
- position_runqueue((queue*)&rh->waypoint_list, i, type);
+ cur_rte = const_cast<route_head*>(rh);
+ position_runqueue(const_cast<queue*>(&rh->waypoint_list), i, type);
cur_rte = nullptr;
}
register_waypt(const Waypoint* ref, const char)
{
int i;
- Waypoint* wpt = (Waypoint*) ref;
+ Waypoint* wpt = const_cast<Waypoint*>(ref);
for (i = 0; i < waypt_table_ct; i++) {
Waypoint* cmp = waypt_table[i];
static void
enum_waypt_cb(const Waypoint* wpt)
{
- register_waypt((Waypoint*) wpt, 0);
+ register_waypt(const_cast<Waypoint*>(wpt), 0);
}
static void
enum_rtept_cb(const Waypoint* wpt)
{
- register_waypt((Waypoint*) wpt, 1);
+ register_waypt(const_cast<Waypoint*>(wpt), 1);
}
static int
{
/* Cast away const-ness */
- Waypoint* wpp = (Waypoint*) waypointp;
+ Waypoint* wpp = const_cast<Waypoint*>(waypointp);
int curr_new_trkseg;
route_reverse(const route_head* rte_hd)
{
/* Cast away const-ness */
- route_head* rh = (route_head*) rte_hd;
+ route_head* rh = const_cast<route_head*>(rte_hd);
queue* elem, *tmp;
QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
ENQUEUE_HEAD(&rh->waypoint_list, dequeue(elem));
rte_desc = trk->rte_desc;
}
- trk_out = (route_head*)trk;
+ trk_out = const_cast<route_head*>(trk);
}
static void
this_time += (wpt->GetCreationTime().toTime_t() - trkpt_out->GetCreationTime().toTime_t());
}
- trkpt_out = (Waypoint*)wpt;
+ trkpt_out = const_cast<Waypoint*>(wpt);
}
static void
{
track_index++;
track_points = 0;
- trk_out = (route_head*)trk;
+ trk_out = const_cast<route_head*>(trk);
trkpt_out = nullptr;
}
gbfprintf(fout, ",0\n");
}
- trkpt_out = (Waypoint*)wpt;
+ trkpt_out = const_cast<Waypoint*>(wpt);
}
static void
void SwapDataFilter::swapdata_cb(const Waypoint* ref)
{
- Waypoint* wpt = (Waypoint*)ref;
+ Waypoint* wpt = const_cast<Waypoint*>(ref);
double x;
x = wpt->latitude;
{
time_t t0, t1;
int sign = 1;
- char* cin = (char*)arg;
+ char* cin = const_cast<char*>(arg);
char c;
t0 = t1 = 0;
queue* elem, *tmp;
if (track->rte_waypt_ct == 0) {
- track_del_head((route_head*)track);
+ track_del_head(const_cast<route_head*>(track));
return;
}
if (!QRegExp(opt_name, Qt::CaseInsensitive, QRegExp::WildcardUnix).exactMatch(track->rte_name)) {
QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
Waypoint* wpt = (Waypoint*)elem;
- track_del_wpt((route_head*)track, wpt);
+ track_del_wpt(const_cast<route_head*>(track), wpt);
delete wpt;
}
- track_del_head((route_head*)track);
+ track_del_head(const_cast<route_head*>(track));
return;
}
}
- track_list[track_ct].track = (route_head*)track;
+ track_list[track_ct].track = const_cast<route_head*>(track);
i = 0;
prev = nullptr;
{
int minimum_points = atoi(opt_minpoints);
if (track->rte_waypt_ct < minimum_points) {
- track_del_head((route_head*)track);
+ track_del_head(const_cast<route_head*>(track));
return;
}
}
i = 0;
strncpy(fmt, "00000101000000", sizeof(fmt));
- cin = (char*)timestr;
+ cin = const_cast<char*>(timestr);
while ((c = *cin++)) {
if (fmt[i] == '\0') {
Waypoint* next_wpt = (Waypoint*) QUEUE_NEXT(&wpt->Q);
if (trackfilter_points_are_same(prev_wpt, wpt) &&
trackfilter_points_are_same(wpt, next_wpt)) {
- track_del_wpt((route_head*)rte, wpt);
+ track_del_wpt(const_cast<route_head*>(rte), wpt);
continue;
}
}
static char
unicsv_compare_fields(const char* s, const field_t* f)
{
- char* name = (char*)f->name;
+ char* name = const_cast<char*>(f->name);
const char* test = s;
char result;
xfree(const void* mem)
#endif
{
- free((void*) mem);
+ free(const_cast<void*>(mem));
#ifdef DEBUG_MEM
debug_mem_output("free, %x, %s, %d\n",
mem, file, line);
#endif
{
size_t newlen = 0;
- char* cin = (char*)str;
+ char* cin = const_cast<char*>(str);
char* newstr;
while ((newlen < sz) && (*cin != '\0')) {
{
char* m, *s;
- s = (char*)str;
- m = (char*)match;
+ s = const_cast<char*>(str);
+ m = const_cast<char*>(match);
while (*m || *s) {
switch (*m) {
{
int ooffs = 0;
char* o, *c;
- char* src = (char*)s;
+ char* src = const_cast<char*>(s);
int olen = strlen(src);
int slen = strlen(search);
int rlen = strlen(replace);
prev = '\0';
ylen = 0;
- for (cin = (char*)human_datef; *cin; cin++) {
+ for (cin = const_cast<char*>(human_datef); *cin; cin++) {
char okay = 1;
if (toupper(*cin) != 'Y') {
cout = result;
prev = '\0';
- for (cin = (char*)human_timef; *cin; cin++) {
+ for (cin = const_cast<char*>(human_timef); *cin; cin++) {
int okay = 1;
if (isalpha(*cin)) {
if (case_ignore_strcmp(val, ap->argstring) == 0) {
c = "";
} else {
- c = (char*)val;
+ c = const_cast<char*>(val);
}
switch (ap->argtype & ARGTYPE_TYPEMASK) {
if (opt) {
found = 1;
assign_option(svecname, ap, opt);
- xfree((char*)opt);
+ xfree(const_cast<char*>(opt));
continue;
}
}
if (opt) {
found = 1;
assign_option(svecname, ap, opt);
- xfree((char*)opt);
+ xfree(const_cast<char*>(opt));
continue;
}
}